//其实页面可以和movie-order页面复用
const app = getApp();
Page({
  data: {
    orderList: [],
    currentId: 0,

    order:{},
    pageNum: 1,
    pageSize: 10,
    has: true,
    loading: false,
    swiperViewHeight: 0,
  },
  onLoad() {
    this.initData()
  },
  changeItem(e) {
    // console.log(e.target.dataset)
    this.setData({
      currentId: e.target.dataset.currentid
    })
  },
  initData() {
    this.getList()
  },
  getList(){
    var that = this;

     // 粉丝列表
    if (that.data.loading) return
  
    that.data.loading = true;
    var pageNum = that.data.pageNum;
    var pageSize = that.data.pageSize;
    wx.request({
      url: app.globalData.url + '/app/operate/myIntroduction',
      method: 'POST',
      data: {
        pageNum,
        pageSize
      },
      header: {
        'Accept': 'application/json',
        'consumerId': app.globalData.userInfo.consumerId
      },
      success: function (res) {
        if (res.data.code == 200) { 
          const orderList = res.data.data.fans
          const order = {
            fansCount: res.data.data.fansCount,
            monthAddFansCount: res.data.data.monthAddFansCount,
            todayFansCount: res.data.data.todayFansCount,
          }
          that.setData({
            orderList,
            order
          })
          that.setSwiperHeight();
          that.data.loading = false;
        }
      }
    })
  },
  setSwiperHeight: function () {
    var query = wx.createSelectorQuery();
    //选择id
    var that = this;
    query.selectAll('.swiperH').boundingClientRect(function (rect) {
      console.log(rect[0].height)
      var itemsLength = 0;
      itemsLength = rect[0].height*that.data.orderList.length + 18;
      that.setData({
        swiperViewHeight: itemsLength
      })
    }).exec();
  },
})